import { makeAutoObservable } from 'mobx';
import { injectable } from 'inversify';
import { UserEntity } from './user.entity.ts';
import { CreateUser } from './interface.ts';

@injectable()
export class UserModel {
  user = new UserEntity();
  connectedUsers: UserEntity[] = [];

  constructor() {
    makeAutoObservable(this);
  }

  initialize(param: CreateUser) {
    this.user.name = param.name;
    this.user._initialized = true;
  }

  addConnectedUser(user: UserEntity) {
    this.connectedUsers.push(user);
  }

  dispose() {
    this.user = new UserEntity();
    this.connectedUsers = [];
  }
}
